package com.luguokong.pet_rescue.service;

import com.luguokong.pet_rescue.mapper.EssayMapper;
import com.luguokong.pet_rescue.pojo.Essay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class EssayService {

    @Autowired
    private EssayMapper essayMapper;

    public int insertEssay(Essay essay){
        int i = essayMapper.insertEssay(essay);
        return i;
    }
    public int deleteEssayById(int essayId){
        int i = essayMapper.deleteEssayById(essayId);
        return i;
    }
    public int updateEssayById(Essay essay){
        int i = essayMapper.updateEssayById(essay);
        return i;
    }
    public Essay selectEssayById(int essayId){
        Essay essay = essayMapper.selectEssayById(essayId);
        return essay;
    }
    public List<Essay> selectPubEssayAllByUserId(int userId){
        List<Essay> essayList = essayMapper.selectPubEssayAllByUserId(userId);
        return essayList;
    }
    public List<Essay> selectUnPubEssayAllByUserId(int userId){
        List<Essay> essayList = essayMapper.selectUnPubEssayAllByUserId(userId);
        return essayList;
    }
    public List<Essay> selectEssayAll(){
        List<Essay> essayList = essayMapper.selectEssayAll();
        return essayList;
    }

    public List<Essay> selectEssayAllByPageNumByPageSize(int pageNum, int pageSize){
        List<Essay> essayList = essayMapper.selectEssayAllByPageNumByPageSize(pageNum, pageSize);
        return essayList;
    }

    public int selectDataCount(){
        int i = essayMapper.selectDataCount();
        return i;
    }

    public int deleteEssayByEssayIdArray(int [] essayIdArr){
        int i = essayMapper.deleteEssayByEssayIdArray(essayIdArr);
        return i;
    }

//    查询近六个月按月分组的数据
    public List<Map<String, Number>> selectCountByRecentSixMGroupByMonth(){
        List<Map<String, Number>> mapList = essayMapper.selectCountByRecentSixMGroupByMonth();
        return mapList;
    }


}
